<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="订单编号">
              <j-input v-model="queryParam.orderId" placeholder="请输入订单编号"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="车辆发票类型">
              <a-select v-model="queryParam.invoiceType" placeholder="请选择车辆发票类型">
                <a-select-option value="1">
                  纸质发票
                </a-select-option>
                <a-select-option value="2">
                  电子发票
                </a-select-option>
              </a-select>
              <!-- <a-date-picker placeholder="请输入车型配置" v-model="queryParam.carTypeConfiguration"></a-date-picker> -->
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="发票编号">
              <j-input v-model="queryParam.no" placeholder="请输入发票编号"></j-input>
              <!-- <a-date-picker placeholder="请输入车型配置" v-model="queryParam.carTypeConfiguration"></a-date-picker> -->
            </a-form-item>
          </a-col>
<!--          <template v-if="toggleSearchStatus">-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="车辆vin码">-->
<!--                <j-input v-model="queryParam.vin" placeholder="请输入车辆vin码"></j-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="车辆颜色">-->
<!--                <j-input v-model="queryParam.outsideColor" placeholder="请输入车辆颜色"></j-input>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--            <a-col :md="6" :sm="8">-->
<!--              <a-form-item label="销售状态">-->
<!--                <a-radio-group v-model="queryParam.status">-->
<!--                  <a-radio :value="1">-->
<!--                    订单-->
<!--                  </a-radio>-->
<!--                  <a-radio :value="2">-->
<!--                    合同-->
<!--                  </a-radio>-->
<!--                </a-radio-group>-->
<!--              </a-form-item>-->
<!--            </a-col>-->
<!--          </template>-->
          <a-col :md="6" :sm="8">
            <span class="table-page-search-submitButtons" style="float: left; overflow: hidden">
              <a-button icon="search" type="primary" @click="searchQuery">查询</a-button>
              <a-button
                icon="reload"
                style="margin-left: 8px"
                type="primary"
                @click="searchReset"
              >重置</a-button>
<!--              <a style="margin-left: 8px" @click="handleToggleSearch">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button icon="plus" type="primary" @click="handleAdd">新增</a-button>
<!--      <a-button icon="download" type="primary" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>-->
<!--      <a-upload-->
<!--        :action="importExcelUrl"-->
<!--        :headers="tokenHeader"-->
<!--        :multiple="false"-->
<!--        :showUploadList="false"-->
<!--        name="file"-->
<!--        @change="handleImportExcel"-->
<!--      >-->
<!--        <a-button icon="import" type="primary">导入</a-button>-->
<!--      </a-upload>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel2">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        :scroll="{ x: 1100 }"
        bordered
        rowKey="id"
        size="middle"
        @change="handleTableChange"
      >
        <span slot="operation" slot-scope="text, record">
          <a-button @click="showModal(record)">作废</a-button>
          <a-modal v-model="visible2" title="作废提示" @ok="getInfo(record)">
            <p>是否对该条记录进行作废？作废后将无法恢复！</p>
          </a-modal>
        </span>
        <span
          slot="filterDepositAttribute"
          slot-scope="depositAttribute"
        >{{ depositAttribute | filterDepositAttribute(depositAttribute) }}</span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!--  <cxmOrderManager-modal ref="modalForm" @ok="modalFormOk"></cxmOrderManager-modal> -->
    <vehicle-register-model ref="modalForm" @ok="modalFormOk"></vehicle-register-model>
  </a-card>
</template>

<script>
import VehicleRegisterModel from './VehicleRegisterModel.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
import moment from 'moment'

export default {
  name: 'VehicleRegister',
  mixins: [JeecgListMixin],
  components: {
    VehicleRegisterModel,
    JInput,
    moment
  },
  data() {
    return {
      description: 'cxm-订单管理页面',
      visible: false,
      ipaginations: {},
      visible2: false,
      // 表头
      columns: [
        {
          title: '订单编号',
          align: 'center',
          dataIndex: 'orderId'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'invoiceStatus'
        },
        {
          title: '发票金额(元)',
          align: 'center',
          dataIndex: 'invoiceAmount'
        },
        {
          title: '发票类型',
          align: 'center',
          dataIndex: 'invoiceType'
        },
        {
          title: '发票代码',
          align: 'center',
          dataIndex: 'code'
        },
        {
          title: '发票编号',
          align: 'center',
          dataIndex: 'no'
        },
        {
          title: '开票日期',
          align: 'center',
          dataIndex: 'date'
        },
        {
          title: '税率',
          align: 'center',
          dataIndex: 'taxRate'
        },
        {
          title: '不含税价',
          align: 'center',
          dataIndex: 'excludingTaxPrice'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          align: 'center',
          width: 152,
          fixed: 'right',
          scopedSlots: {
            customRender: 'operation'
          }
        }
      ],

      url: {
        list: '/sale/cxmSaleInvoiceInfo/list',
        delete: '/sale/cxmSaleInvoiceInfo/delete',
        deleteBatch: '/sale/cxmSaleInvoiceInfo/deleteBatch',
        exportXlsUrl: 'cxm/cxmOrderManager/exportXls',
        importExcelUrl: 'cxm/cxmOrderManager/importExcel'
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    close() {
      this.$emit('close')
      this.visible2 = false
    },
    showModal(record) {
      this.visible2 = true
      this.onSelectedRecordId = record.id

    },
    getInfo() {
      this.axios.post('http://192.168.7.206:9099/cxmsystem/sale/cxmSaleInvoiceInfo/delete?id=' + this.onSelectedRecordId
      ).then(res => {
        let rs = res.result
        console.log(rs)
        this.close()
        this.loadData()
      }).catch(err => {
        // this.expRoute("2",err.message)
      })
    },
  },
  filters: {
    filterTime(time) {
      return moment(time).format('YYYY-MM-DD')
    },
    filterDepositAttribute(depositAttribute) {
      switch (depositAttribute) {
        case '1':
          return '可退'
          break
        case '2':
          return '不可退'
          break
        case '3':
          return '有条件可退'
          break
      }
    }
  }
}
</script>
<style scoped>
@import "~@assets/less/common.less";
</style>

